﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using ConstructionBidOnline.Biz;

public partial class AddEditJobDescription : System.Web.UI.Page
{

    #region Event Handlers

    # region Page load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["userid"] != null)
            {
                if (Request.QueryString["Action"].ToString() == "Edit")
                {
                    txtjobdescription.Text = Job.GetJobByID(Session["jobid"].ToString()).JobDescription;
                }
            }
            else
            {
                String strscript = "<script language=javascript>refreshandclose();</script>";
                if (!Page.IsStartupScriptRegistered("clientScript"))
                    Page.RegisterStartupScript("clientScript", strscript);
            }
        }
    }

    #endregion

    #region Add / Edit Job Description Submit Click

    protected void btnAEJDSubmit_Click(object sender, ImageClickEventArgs e)
    { 
        Job jobObj = Job.GetJobByID(Session["jobid"].ToString());
        if (Request.QueryString["Action"].ToString() == "Edit")
        {
            jobObj.JobDescription = txtjobdescription.Text;
        }
        else
        {
            jobObj.JobDescription = jobObj.JobDescription + "\n\n" + txtjobdescription.Text;
        }
        Job.Update(jobObj);

        pnlbuttons.Visible = false;
        lblerror.Visible = true;
        lblerror.Text = "Job description updated successfully.<br/> <a href='javascript: void(0)' onclick='javascript: refreshandclose()'> Close this window</a>";
    }

    #endregion

    #endregion

}
